﻿using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Debugger.Interop;

namespace Microsoft.WowAddonStudio.Lua.RuntimeService.DebugEngine
{
    /// <summary>
    /// Represents an enhanced version of an expression evaluator (EE) for Lua.
    /// </summary>
    [ComVisible(true)]
    [Guid(GuidStrings.LuaDebugExpressionEvaluator)]
    public class LuaDebugExpressionEvaluator : IDebugExpressionEvaluator2
    {
        public LuaDebugExpressionEvaluator()
        {
            Trace.WriteLine("LuaDebugExpressionEvaluator initialized.");
        }

        /// <summary>
        /// Gets the local variables, arguments, and other properties of a method.
        /// </summary>
        /// <param name="pSymbolProvider"></param>
        /// <param name="pAddress"></param>
        /// <param name="pBinder"></param>
        /// <param name="fIncludeHiddenLocals"></param>
        /// <param name="ppProperty"></param>
        /// <returns></returns>
        int IDebugExpressionEvaluator.GetMethodProperty(IDebugSymbolProvider pSymbolProvider, IDebugAddress pAddress,
                                                        IDebugBinder pBinder, int fIncludeHiddenLocals,
                                                        out IDebugProperty2 ppProperty)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Converts a method location and offset into a memory address.
        /// </summary>
        /// <param name="upstrFullyQualifiedMethodPlusOffset"></param>
        /// <param name="pSymbolProvider"></param>
        /// <param name="pAddress"></param>
        /// <param name="pBinder"></param>
        /// <param name="ppProperty"></param>
        /// <returns></returns>
        int IDebugExpressionEvaluator.GetMethodLocationProperty(string upstrFullyQualifiedMethodPlusOffset,
                                                                IDebugSymbolProvider pSymbolProvider,
                                                                IDebugAddress pAddress, IDebugBinder pBinder,
                                                                out IDebugProperty2 ppProperty)
        {
            ppProperty = null;
            return VSConstants.E_NOTIMPL;
        }

        /// <summary>
        /// Converts an expression string to a parsed expression.
        /// </summary>
        /// <param name="upstrExpression"></param>
        /// <param name="dwFlags"></param>
        /// <param name="nRadix"></param>
        /// <param name="pbstrError"></param>
        /// <param name="pichError"></param>
        /// <param name="ppParsedExpression"></param>
        /// <returns></returns>
        public int Parse(string upstrExpression, uint dwFlags, uint nRadix, out string pbstrError, out uint pichError,
                         out IDebugParsedExpression ppParsedExpression)
        {
            pbstrError = null;
            ppParsedExpression = null;
            pichError = 0;
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Parses the specified upstr expression.
		/// </summary>
		/// <param name="upstrExpression">The upstr expression.</param>
		/// <param name="dwFlags">The dw flags.</param>
		/// <param name="nRadix">The n radix.</param>
		/// <param name="pbstrError">The PBSTR error.</param>
		/// <param name="pichError">The pich error.</param>
		/// <param name="ppParsedExpression">The pp parsed expression.</param>
		/// <returns></returns>
        int IDebugExpressionEvaluator.Parse(string upstrExpression, uint dwFlags, uint nRadix, out string pbstrError,
                                            out uint pichError, out IDebugParsedExpression ppParsedExpression)
        {
            ppParsedExpression = null;
            pbstrError = null;
            pichError = 0;
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Gets the method property.
		/// </summary>
		/// <param name="pSymbolProvider">The p symbol provider.</param>
		/// <param name="pAddress">The p address.</param>
		/// <param name="pBinder">The p binder.</param>
		/// <param name="fIncludeHiddenLocals">The f include hidden locals.</param>
		/// <param name="ppProperty">The pp property.</param>
		/// <returns></returns>
        public int GetMethodProperty(IDebugSymbolProvider pSymbolProvider, IDebugAddress pAddress, IDebugBinder pBinder,
                                     int fIncludeHiddenLocals, out IDebugProperty2 ppProperty)
        {
            ppProperty = null;
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Gets the method location property.
		/// </summary>
		/// <param name="upstrFullyQualifiedMethodPlusOffset">The upstr fully qualified method plus offset.</param>
		/// <param name="pSymbolProvider">The p symbol provider.</param>
		/// <param name="pAddress">The p address.</param>
		/// <param name="pBinder">The p binder.</param>
		/// <param name="ppProperty">The pp property.</param>
		/// <returns></returns>
        public int GetMethodLocationProperty(string upstrFullyQualifiedMethodPlusOffset,
                                             IDebugSymbolProvider pSymbolProvider, IDebugAddress pAddress,
                                             IDebugBinder pBinder, out IDebugProperty2 ppProperty)
        {
            ppProperty = null;
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Sets the locale.
		/// </summary>
		/// <param name="wLangID">The w lang ID.</param>
		/// <returns></returns>
        int IDebugExpressionEvaluator.SetLocale(ushort wLangID)
        {
            return VSConstants.E_NOTIMPL;
        }

        /// <summary>
        /// Determines which language to use to create printable results.
        /// </summary>
        /// <param name="wLangID"></param>
        /// <returns></returns>
        public int SetLocale(ushort wLangID)
        {
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Sets the registry root.
		/// </summary>
		/// <param name="ustrRegistryRoot">The ustr registry root.</param>
		/// <returns></returns>
        int IDebugExpressionEvaluator.SetRegistryRoot(string ustrRegistryRoot)
        {
            return VSConstants.E_NOTIMPL;
        }

        /// <summary>
        /// Sets the registry root. Used for side-by-side debugging.
        /// </summary>
        /// <param name="ustrRegistryRoot"></param>
        /// <returns></returns>
        public int SetRegistryRoot(string ustrRegistryRoot)
        {
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Sets the cor path.
		/// </summary>
		/// <param name="pcstrCorPath">The PCSTR cor path.</param>
		/// <returns></returns>
        public int SetCorPath(string pcstrCorPath)
        {
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Stops and cleans up the expression evaluator.
		/// </summary>
		/// <returns></returns>
        public int Terminate()
        {
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Sets the callback.
		/// </summary>
		/// <param name="pCallback">The p callback.</param>
		/// <returns></returns>
        public int SetCallback(IDebugSettingsCallback2 pCallback)
        {
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Preloads the modules.
		/// </summary>
		/// <param name="pSym">The p sym.</param>
		/// <returns></returns>
        public int PreloadModules(IDebugSymbolProvider pSym)
        {
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Gets the service.
		/// </summary>
		/// <param name="uid">The uid.</param>
		/// <param name="ppService">The pp service.</param>
		/// <returns></returns>
        public int GetService(Guid uid, out object ppService)
        {
            ppService = null;
            return VSConstants.E_NOTIMPL;
        }

		/// <summary>
		/// Sets the I debug IDE callback.
		/// </summary>
		/// <param name="pCallback">The p callback.</param>
		/// <returns></returns>
        public int SetIDebugIDECallback(IDebugIDECallback pCallback)
        {
            return VSConstants.E_NOTIMPL;
        }

        #region IDebugExpressionEvaluator3 Members


		/// <summary>
		/// Parse2s the specified upstr expression.
		/// </summary>
		/// <param name="upstrExpression">The upstr expression.</param>
		/// <param name="dwFlags">The dw flags.</param>
		/// <param name="nRadix">The n radix.</param>
		/// <param name="pSymbolProvider">The p symbol provider.</param>
		/// <param name="pAddress">The p address.</param>
		/// <param name="pbstrError">The PBSTR error.</param>
		/// <param name="pichError">The pich error.</param>
		/// <param name="ppParsedExpression">The pp parsed expression.</param>
		/// <returns></returns>
        public int Parse2(string upstrExpression, uint dwFlags, uint nRadix, IDebugSymbolProvider pSymbolProvider,
                          IDebugAddress pAddress, out string pbstrError, out uint pichError,
                          out IDebugParsedExpression ppParsedExpression)
        {
            pbstrError = null;
            ppParsedExpression = null;
            pichError = 0;
            return VSConstants.E_NOTIMPL;
        }

        #endregion
    }
}
